<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/bootstrap.css">
    <title>Document</title>
</head>

<body>
    <nav class="navbar navbar-inverse" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">智游问答系统</a>
            </div>
          
        </div>
    </nav>

    <div class="container">
        <form action="/questions/ask" method="POST">
            <div class="form-group">
                <label for="name">请输入您的问题</label>
                <textarea class="form-control" name="content" id="" cols="30" rows="10"></textarea>
               
            </div>
            <input type="submit" class="btn btn-success btn-block" value="提交问题">
        </form>
    </div>
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>
    <script>
        $('form').submit(function (event) {
            // prevent阻止  default 默认
            event.preventDefault()
            $.post('/questions/ask', $('form').serialize(), function (data) {

                if (data == '提问成功') {
                    window.location.href = 'index.html'
                }
                else {
                    alert(data)
                }
            })
        })
    </script>
</body>

</html>